<template>
	<view>
		<view class="percenter">
			<view class="bgc">
				<image src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1586636913848&di=f9f441cbc004001f0013668a2817fc69&imgtype=0&src=http%3A%2F%2Fpicm.bbzhi.com%2Fjunshibizhi%2Fgaoqingxiyouhuashifeijibizhi%2Fgaoqingxiyouhuashifeijibizhi_424421_m.jpg" mode=""></image>
				<view class="shadow"></view>
			</view>
			<tupian @func="getMsgFormSon"></tupian>
			<view>
				<h3>个人信息</h3>
			</view>
			<form @submit="formSubmit">
				<view class="merbinfo">
					<view class="bottom">
						<view style="opacity: 1;">
							<input v-show="false" name="imageUrl" type="text" :value="imageUrl" />
						</view>
						<view>
							<p class="title">真实姓名</p>
							<input name="realName" class="cont" type="text" :value="userinformation.realName==''||userinformation.realName==null?'':userinformation.realName" />
						</view>
						<view>
							<p class="title">性别</p>
							<input name="sex" class="cont" type="text" :value="userinformation.sex==''||userinformation.sex==null?'':userinformation.sex" />
						</view>
						<view>
							<p class="title">年龄</p>
							<input name="age" class="cont" type="number" :value="userinformation.age==''||userinformation.age==null?'':userinformation.age" />
						</view>
					</view>
					<view class="bottom">
						<view>
							<p class="title">学员编号</p>
							<input name="phone" class="cont" type="number" :value="userinformation.phone==''||userinformation.phone==null?'':userinformation.phone" />
						</view>
						<view>
							<p class="title">所在地</p>
							<input name="address" class="cont" type="text" :value="userinformation.address==''||userinformation.address==null?'':userinformation.address" />
						</view>
					</view>
					<view class="bottom">
						<view>
							<p class="title">学校</p>
							<input name="school" class="cont" type="text" :value="userinformation.school==''||userinformation.school==null?'':userinformation.school" />
						</view>
						<view>
							<p class="title">曾就读学校</p>
							<input name="onceSchool" class="cont" type="text" :value="userinformation.onceSchool==''||userinformation.onceSchool==null?'':userinformation.onceSchool" />
						</view>
					</view>
					<view class="bottom">
						<view>
							<p class="title">年级</p>
							<input name="grade" class="cont" type="text" :value="userinformation.grade==''||userinformation.grade==null?'':userinformation.grade" />
						</view>
						<view>
							<p class="title">身份证号</p>
							<input name="idCard" class="cont" type="text" :value="userinformation.idCard==''||userinformation.idCard==null?'':userinformation.idCard" />
						</view>
						<view>
							<p class="title">邮寄地址</p>
							<input name="mailAddress" class="cont" type="text" :value="userinformation.mailAddress==''||userinformation.mailAddress==null?'':userinformation.mailAddress" />
						</view>
					</view>
				</view>
				<view>
					<h3>教师信息</h3>
				</view>
				<view class="merbinfo">
					<view class="bottom">
						<view>
							<p class="title">学校负责人</p>
							<input name="schoolPerson" class="cont" type="text" :value="userinformation.schoolPerson==''||userinformation.schoolPerson==null?'':userinformation.schoolPerson" />
						</view>
						<view>
							<p class="title">电话</p>
							<input name="schoolPersonPhone" class="cont" type="number" :value="userinformation.schoolPersonPhone==''||userinformation.schoolPersonPhone==null?'':userinformation.schoolPersonPhone" />
						</view>
					</view>
					<view class="bottom">
						<view>
							<p class="title">辅导老师</p>
							<input name="leaderTeacher" class="cont" type="text" :value="userinformation.leaderTeacher==''||userinformation.leaderTeacher==null?'':userinformation.leaderTeacher" />
						</view>
						<view>
							<p class="title">电话</p>
							<input name="leaderTeacherPhone" class="cont" type="number" :value="userinformation.leaderTeacherPhone==''||userinformation.leaderTeacherPhone==null?'':userinformation.leaderTeacherPhone" />
						</view>
					</view>
					<view class="bottom">
						<view>
							<p class="title">家长</p>
							<input name="parent" class="cont" type="text" :value="userinformation.parent==''||userinformation.parent==null?'':userinformation.parent" />
						</view>
						<view>
							<p class="title">电话</p>
							<input name="parentPhone" class="cont" type="number" :value="userinformation.parentPhone==''||userinformation.parentPhone==null?'':userinformation.parentPhone" />
						</view>
					</view>
				</view>
				<button v-show="!flag" form-type="submit">提交</button>
			</form>
			<button v-show="flag" @click="fanhui">返回</button>
		</view>
	</view>
</template>

<script>
	import tupian from '../../components/tupian/tupian.vue'
	import {bjuserInfo,getuserInfo} from '../../apis'
	export default{
		data() {
			return{
				imageUrl:'',
				userinformation:{},
				flag:false
			}
		},
		onShow() {
			getuserInfo().then((res)=>{
				let [err,data] = res
				this.userinformation = data.data.data
				console.log(this.userinformation.imageUrl)
				if(this.userinformation.imageUrl !== ''){
					this.imageUrl = this.userinformation.imageUrl
				}else{
					console.log("ok")
				}
			})
		},
		methods:{
			formSubmit: function(e) {
				bjuserInfo({
					"address": e.detail.value.address,
					"age": e.detail.value.age,
					"grade": e.detail.value.grade,
					"idCard": e.detail.value.idCard,
					"imageUrl": e.detail.value.imageUrl,
					"leaderTeacher": e.detail.value.leaderTeacher,
					"leaderTeacherPhone": e.detail.value.leaderTeacherPhone,
					"mailAddress": e.detail.value.mailAddress,
					"onceSchool": e.detail.value.onceSchool,
					"parent": e.detail.value.parent,
					"parentPhone": e.detail.value.parentPhone,
					"phone": e.detail.value.phone,
					"realName": e.detail.value.realName,
					"school": e.detail.value.school,
					"schoolPerson": e.detail.value.schoolPerson,
					"schoolPersonPhone": e.detail.value.schoolPersonPhone,
					"sex": e.detail.value.sex
				}).then((res)=>{
					let [err,data] = res
					console.log(data)
					uni.showToast({
						title:'修改成功！',
						icon:'success'
					})
					this.flag = true
				})
			},
			getMsgFormSon(data){
				console.log('父组件接收到的数据')
				console.log(data)
				this.imageUrl = data
			},
			fanhui(){
				uni.switchTab({
					url:'../my/my'
				})
			}
		},
		
		components:{tupian}
	}
</script>
<style lang="scss" scoped>
	.percenter{
		width: 96%;
		margin: 0 auto;
		position: relative;
		image{
			width: 100%;
			height: 150px;
			vertical-align: middle;
		}
		.shadow{
			width: 100%;
			height: 60px;
			background-color: rgba(225,225,225,.5);
			position: absolute;
			transform: translateY(-50%);
		}
		.photo{
			width: 30%;
			height: 115px;
			position: absolute;
			transform: translateY(-40%);
			right: 20px;
			border: 2px solid #fff;
			
			image{
				width: 100%;
				height: 100%;
			}
		}
		h3{
			height: 20px;
			height: 30px;
			line-height: 30px;
			font-size: 14px;
			color: #9a9999;
			font-weight: 900;
			padding-left: 10px;
			background-color: #eee;
			
		}
		.merbinfo{
			margin: 5px 15px;
			line-height: 20px;
			.title{
				font-size: 12px;
				color: #737272;
			}
			
			.bottom{
				view{
					margin-bottom: 10px;
				}
				.cont{
					width: 100%;
					font-size: 14px;
					color: #000000;
					border-bottom:1px solid #ccc;
					text-align: center;
					display: block;
					height: 50px;
					transform: translateY(-30%);
				}
			}
		}
		button{
			margin-bottom: 15px;
		}
	}
</style>


